<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport"
			content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
		<link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
		<link rel="stylesheet" href="../../../css/common.css" media="all">
	</head>
	<body>
		<div class="layui-fluid">
			<div class="layui-row layui-col-space15" id="ledgerDataView">
			</div>


			<div class="layui-row layui-col-space15">
				<div class="layui-col-md12">
					<div class="layui-card">
						<div class="layui-card-body">
							<!-- 搜索 -->
							<form class="layui-form search" id="form" onsubmit="return false" action="##">
								<div class="layui-inline search_inline">
									<label class="layui-form-label">会员编号：</label>
									<div class="layui-input-inline">
										<input class="layui-input" lay-verify="" placeholder="会员编号" name="customerid"
											autocomplete="off">
									</div>
								</div>
								<div class="layui-inline search_inline">
									<label class="layui-form-label">会员手机号：</label>
									<div class="layui-input-inline">
										<input class="layui-input" lay-verify="" placeholder="会员手机号"
											name="customerMobile" autocomplete="off">
									</div>
								</div>
								<div class="layui-inline search_inline" id="timeall">
									<label class="layui-form-label">时间：</label>
									<div class="layui-input-inline"  id="timeMin">
										<input class="layui-input" style="width: 300px;" id="choosetime"
											placeholder="时间" autocomplete="off">
										<input class="layui-input" type="text" name="stat_date" placeholder=""
											autocomplete="off" style="display: none;">
										<input class="layui-input" type="text" name="end_date" placeholder=""
											autocomplete="off" style="display: none;">
									</div>
									<div class="layui-input-inline" id="timeSelect" ></div>
								</div>
								<button class="layui-btn search_inline" lay-submit="" lay-filter="search"
									data-type="reload">搜索</button>
								<button class="layui-btn layui-btn-primary search_inline" type="reset">重置</button>
							</form>
							<div class="layui-tab layui-tab-brief" lay-filter="changetab">
								<ul class="layui-tab-title" id="view_ul" style="margin-bottom: 10px;"></ul>
							</div>
							<!-- 搜索 -->

							<table style="display: none !important;" class="layui-hide" id="test-table-operate" lay-filter="test-table-operate"></table>
							<script type="text/html" id="zizeng">
							{{d.LAY_TABLE_INDEX+1}}
							</script>
							<script type="text/html" id="test-table-operate-barDemo">
								<!-- <a class="layui-btn layui-btn-xs" lay-event="detail">详情</a> -->
							<a class="layui-btn layui-btn-xs" lay-event="edit">修改</a>
							<!-- <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
							  <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a> -->
							</script>
							
							<div id="line_details" >
								<div id="chart-money" style="height:400px;"></div>
								<table class="layui-hide" id="test-table-operate2" lay-filter="test-table-operate2"></table>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<script type="text/html" id="time_ul">
			<select name="year" lay-verify="required">
				{{# layui.each(d, function(index, item){ }}
					<option value="{{ item}}">{{ item }}</option>
					{{# }); }}
			</select>
		</script>
        <script type="text/html" id="demo_ul">
			<li class="layui-this" lay-id='1'>明细</li>
			<li  lay-id='2'>按日</li>
			<li class="" lay-id='3'>按月</li>
			<li class="" lay-id='4'>按年</li>
			<!-- {{# layui.each(d, function(index, item){ }}
				<li class="" lay-id='{{ item.value }}'>{{ item.name }}</li>
				{{# }); }} -->
		</script>
		<script src="../../../layuiadmin/layui/layui.js"></script>
		<script src="../../../js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../../js/common.js"></script>
		<script src="../../../js/echarts.js"></script>
		<script>
			layui.config({
				base: '../../../layuiadmin/' //静态资源所在路径
			}).extend({
				index: 'lib/index' //主入口模块
			}).use(['index', 'table', 'form', 'laytpl'], function() {
				var table = layui.table,
					$ = layui.$,
					form = layui.form,
					laytpl = layui.laytpl,
					laydate = layui.laydate,
					element = layui.element,
					admin = layui.admin;
					
				var getTpl = demo_ul.innerHTML,
					view = document.getElementById('view_ul');
					view.innerHTML = getTpl;	
					laydate.render({
						elem: '#choosetime',
						type: 'datetime',
						range: true,
						done: function(value, date) {
							$('input[name=stat_date]').val(value.split(' - ')[0]);
							$('input[name=end_date]').val(value.split(' - ')[1]);
						}
					});
                var type=getParam('type');
                // var accountname=getParam('scene')
                // var accountname=getParam('accountname')
                // console.log(accountname,"==========accountname")
				var _data = {
					scenename:"",
					accountid:"",
					scene:""
				}
				// if(getParam('id')){
				// 	if(getParam('id').includes(',')){
				// 		_data.accountids=getParam('id')
				// 	}else{
				// 		_data.accountid=getParam('id')
				// 	}
				// }
				_data.scenename=getParam('scene')
				if(type=='1'){
					if(_data.scenename=='线上交易总额' || _data.scenename=='线上订单量'){
						_data.scene=1
					}else if(_data.scenename=='线下订单量' || _data.scenename=='线下交易总额'){
						_data.scene=2
					}
				}
				if(getParam('scene')=='商家积分'){
					_data.accountid=105
				}else if(getParam('scene')=='商家余额'){
					_data.accountid=107
				}
				if(getParam('scene')){
					_data.scenename=getParam('scene')
				}
				$('#timeSelect').css('display','none')
				var year=''
				var yearange=[]
				let num = new Date(); // 获取当前年
				year = num.getFullYear()
				$('select[name=year]').val(year)
				for (var i = 4; i > -1; i--) {
					let time = num.getFullYear() - i
					yearange.push(time)
				}
					view = document.getElementById('timeSelect');
					laytpl(time_ul.innerHTML).render(yearange, function(html) {
						view.innerHTML = html;
					});
				console.log(yearange,'yearange222')

				record_type_show('option');
				initdata();

				function accountid_on(e) {
					console.log(e);
				}

             
				
				function account(e) {
					$.get(server.sys_member_account_total_info, function(res, status) {
						if (status == 'success') {
							if (res.code == 0) {
								res.member_account.data.map((item, index) => {
									item.name = (e.find((val) => item.accountid == val.accountid))
										.accountname
								})

								console.log(res.member_account.data);
								var data = res.member_account.data;
								var ledgerDataView = document.getElementById('ledgerDataView');
								laytpl(ledgerDataTPL.innerHTML).render(data, function(html) {
									ledgerDataView.innerHTML = html;
								});
								$(".accoutid_on li").on('click', function() {
									console.log($(this).index());
									_data.accountid = data[$(this).index()].accountid
									$('select[name=accountid]').val(_data.accountid).toString()
									console.log($('select[name=accountid]').val());
									initdata()
									// $(this).addClass("active").siblings().removeClass("active");
								})
								// laytpl(ledgerDataTPL.innerHTML).render(data, function(html) {
								// 	ledgerDataView.innerHTML = html;
								// });
							} else {
								layer.msg(res.msg);
							}
						} else {
							layer.msg('服务器连接错误');
						}
					});
				}
				// initChartMoney() 明细
				function initdata() { 
					let url=''
					// if(type=='1' || type=='2'){
					// 	url=server.queryjylist
					// }else if(type=='3' || type=='4'){
					// 	url=server.op_querybillslist
					// }
                    if(type=='1'){
						url=server.hssd_shop_jylist
					}else if(_data.scenename=='商家佣金'){
						url=server.hssd_shop_yjlist
                    }else if(_data.scenename=='商家积分'){
						url=server.hssd_shop_xfjflist
                    }else if(_data.scenename=='商家余额'){
						url=server.hssd_shop_yelist
                    }else if(_data.scenename=='直推奖励'){
						url=server.hssd_shop_jfztlist
                    }else if(_data.scenename=='间推奖励'){
						url=server.hssd_shop_jfjtlist
                    }else if(_data.scenename=='团队奖励'){
						url=server.hssd_shop_jftdlist
                    }else if(_data.scenename=='积分收入'){
						url=server.hssd_shop_jfsrlist
                    }else if(_data.scenename=='现金收入'){
						url=server.hssd_shop_xjsrlist
					}
					console.log(_data)
					
					table.render({
						elem: '#test-table-operate',
						url: url,
						height: 'full-105',
						toolbar: true,
						totalRow: true,
						cols: [
							[{
								width: 50,
								field: 'zizeng',
								title: '#',
								fixed: 'left',
								templet: '#zizeng'
							}, 
							{
								field: 'dates',
								width: 200,
								title: '时间',
							},
							
							{
								field: 'memberid',
								width: 200,
								title: '会员编号',
							},
							{
								field: 'name',
								width: 200,
								title: '会员姓名',
							},
							{
								field: 'orderid',
								width: 200,
								title: '订单号',
							},
							{
								field: 'mobile',
								width: 150,
								title: '手机号',
							}, {
								field: 'fee',
								width: 100,
								title: '金额',
								totalRow: '{{= d.TOTAL_NUMS.toFixed(4) }}',
									templet: function(d) {
									return d.income==0?'<span class="text_blue_color">-'+(_data.accountid=='105'?(d.fee/10).toFixed(4):d.fee)+'</span>':'<span class="text_red_color">+'+(_data.accountid=='105'?(d.fee/10).toFixed(4):d.fee)+'</span>'
								}
							}, 
							{
								field: 'type',
								width: 200,
								title: '交易类型',
							}, 
							{
								field: 'notes',
								width: 300,
								title: '备注说明',
							},
							]
						],
						page: true,
						where: _data,
						limit: limit,
						limits: limits,
						request: {
							pageName: 'page',
							limitName: 'size',
						},
						parseData: function(res) { //将原始数据解析成 table 组件所规定的数据
							return {
								"code": res.code, //解析接口状态
								"msg": res.msg, //解析提示文本
								"count": res.bills.pager.total, //解析数据长度
								"data": res.bills.data //解析数据列表
							};
						}
					});
				}
				// 日统计 表格
				function initdataTable() {
					let params={
						tname:tname,
					}
					if(status=='2'){
						params.starttime=$('input[name=stat_date]').val()
						params.endtime=$('input[name=end_date]').val()
					}else if(status=='3'){
						params.starttime=$('select[name=year]').val()+'-01-01 00:00:00'
						params.endtime=$('select[name=year]').val()+'-12-31 23:59:59'
					}
                    if(type==1){
					    var tableurl=server.hssd_shop_jytotal
					}
					if(_data.scene){
						params.scene=_data.scene
					}
					
					console.log(params,'paramsparams')
					$.get(server.sys_account_account,_data, function(res, status) {
						if (status == 'success') {
							if (res.code == 0) {
								var aaa_list = res.account.data
								// account(aaa_list)
								table.render({
									elem: '#test-table-operate2',
									url: tableurl,
									height: 'full-105',
									toolbar: true,
									totalRow: true,
									cols: [
										[ 
										{
											field: 'shopid',
											width: 200,
											title: '店铺编号',
										},{
											field: 'tname',
											width: 200,
											title: '日期',
										},
										{
											field: 'xs_fee',
											width: 200,
											title: '线上交易金额',
										},
										{
											field: 'xx_fee',
											width: 200,
											title: '线下交易金额',
										},
										{
											field: 'fee',
											width: 200,
											title: '交易金额',
										}, {
											field: 'xf_allnum',
											width: 200,
											title: '订单总量',
										}, 
										{
											field: 'xf_online_num',
											width: 200,
											title: '线上订单量',
										}, 
										{
											field: 'xf_offline_num',
											width: 200,
											title: '线下订单量',
										}
										]
									],
									page: true,
									where: params,
									limit: limit,
									limits: limits,
									request: {
										pageName: 'page',
										limitName: 'size',
									},
									parseData: function(res) { //将原始数据解析成 table 组件所规定的数据
									    initChartMoney(res.bills.data)  // 图表数据
										return {
											"code": res.code, //解析接口状态
											"msg": res.msg, //解析提示文本
											"count": res.bills.pager.total, //解析数据长度
											"data": res.bills.data ,//解析数据列表
										};
									}
								});
							} else {
								layer.msg(res.msg);
							}
						} else {
							layer.msg('服务器连接错误');
						}
					});
				}
				
				function xflfTable() {
					let params={
						tname:tname,
					}
					if(status=='2'){
						params.starttime=$('input[name=stat_date]').val()
						params.endtime=$('input[name=end_date]').val()
					}else if(status=='3'){
						params.starttime=$('select[name=year]').val()+'-01-01 00:00:00'
						params.endtime=$('select[name=year]').val()+'-12-31 23:59:59'
					}
					// if(_data.accountids){
					// 	params.accountids=_data.accountids
					// }
					if(_data.accountid){
						params.accountid=_data.accountid
					}
					var tableurl=""
					if(_data.scenename=='商家佣金'){
						tableurl=server.hssd_shop_yjtotal
                    }else if(_data.scenename=='商家积分'){
						tableurl=server.hssd_shop_xfjftotal
					}
					$.get(server.sys_account_account,_data, function(res, status) {
						if (status == 'success') {
							if (res.code == 0) {
								var aaa_list = res.account.data
								table.render({
									elem: '#test-table-operate2',
									url: tableurl,
									height: 'full-105',
									toolbar: true,
									totalRow: true,
									cols: [
										[ 
											{
												field: 'tname',
												width: 350,
												title: '日期',
											},{
												field: 'jf_fee',
												width: 350,
												title: '消费积分总额',
											},
											{
												field: 'jf_fee101',
												width: 350,
												title: '个人消费积分总额（包含团队奖励）',
											},
											{
												field: 'jf_fee105',
												width: 380,
												title: '商家充值积分总额',
											},
										]
									],
									page: true,
									where: params,
									limit: limit,
									limits: limits,
									request: {
										pageName: 'page',
										limitName: 'size',
									},
									parseData: function(res) { //将原始数据解析成 table 组件所规定的数据
									    initChartMoney(res.bills.data)  // 图表数据
										return {
											"code": res.code, //解析接口状态
											"msg": res.msg, //解析提示文本
											"count": res.bills.pager.total, //解析数据长度
											"data": res.bills.data ,//解析数据列表
											
											
										};
									}
								});
							} else {
								layer.msg(res.msg);
							}
						} else {
							layer.msg('服务器连接错误');
						}
					});
				}
				function balanceTable() {
					let params={
						tname:tname,
					}
					if(status=='2'){
						params.starttime=$('input[name=stat_date]').val()
						params.endtime=$('input[name=end_date]').val()
					}else if(status=='3'){
						params.starttime=$('select[name=year]').val()+'-01-01 00:00:00'
						params.endtime=$('select[name=year]').val()+'-12-31 23:59:59'
					}
					// if(_data.accountids){
					// 	params.accountids=_data.accountids
					// }
					if(_data.accountid){
						params.accountid=_data.accountid
					}
					var tableurl=""
					if(_data.scenename=='商家余额'){
						tableurl=server.hssd_shop_yetotal
					}
					$.get(server.sys_account_account,_data, function(res, status) {
						if (status == 'success') {
							if (res.code == 0) {
								var aaa_list = res.account.data
								table.render({
									elem: '#test-table-operate2',
									url: tableurl,
									height: 'full-105',
									toolbar: true,
									totalRow: true,
									cols: [
										[ 
											{
												field: 'tname',
												width: 350,
												title: '日期',
											},{
												field: 'ye_fee',
												width: 350,
												title: '总余额',
											},
											{
												field: 'ye_fee100',
												width: 350,
												title: '会员余额',
											},
											{
												field: 'ye_fee107',
												width: 380,
												title: '商家余额',
											},
										]
									],
									page: true,
									where: params,
									limit: limit,
									limits: limits,
									request: {
										pageName: 'page',
										limitName: 'size',
									},
									parseData: function(res) { //将原始数据解析成 table 组件所规定的数据
										initChartMoney(res.bills.data)  // 图表数据
										console.log(res.bills,'res.bills11111111')
										return {
											"code": res.code, //解析接口状态
											"msg": res.msg, //解析提示文本
											"count": res.bills.pager.total, //解析数据长度
											"data": res.bills.data ,//解析数据列表
										};
									}
								});
							} else {
								layer.msg(res.msg);
							}
						} else {
							layer.msg('服务器连接错误');
						}
					});
					
				}
				function jldataTable() {
					let params={
						tname:tname,
					}
					if(status=='2'){
						params.starttime=$('input[name=stat_date]').val()
						params.endtime=$('input[name=end_date]').val()
					}else if(status=='3'){
						params.starttime=$('select[name=year]').val()+'-01-01 00:00:00'
						params.endtime=$('select[name=year]').val()+'-12-31 23:59:59'
					}
					// if(_data.accountids){
					// 	params.accountids=_data.accountids
					// }
					if(_data.accountid){
						params.accountid=_data.accountid
					}
					var tableurl=""
					if(_data.scenename=='直推奖励'){
						tableurl=server.hssd_shop_jfzttotal
                    }else if(_data.scenename=='间推奖励'){
						tableurl=server.hssd_shop_jfjttotal
                    }else if(_data.scenename=='团队奖励'){
						tableurl=server.hssd_shop_jftdtotal
                    }else if(_data.scenename=='积分收入'){
						tableurl=server.hssd_shop_jfsrtotal
                    }else if(_data.scenename=='现金收入'){
						tableurl=server.hssd_shop_xjsrtotal
					}
					$.get(server.sys_account_account,_data, function(res, status) {
						if (status == 'success') {
							if (res.code == 0) {
								var aaa_list = res.account.data
								table.render({
									elem: '#test-table-operate2',
									url: tableurl,
									height: 'full-105',
									toolbar: true,
									totalRow: true,
									cols: [
										[ 
											{
												field: 'tname',
												// width: 350,
												title: '日期',
											},{
												field: _data.scenename=='直推奖励'?'jfzt_money':_data.scenename=='间推奖励'?'jfjt_money':_data.scenename=='团队奖励'?'jftd_money':_data.scenename=='积分收入'?'jfsr_money':_data.scenename=='现金收入'?'xjsr_money':"",
												// width: 350,
												title: _data.scenename=='现金收入'?'余额':"积分",
											},
											// {
											// 	field: 'ye_fee100',
											// 	width: 350,
											// 	title: '会员余额',
											// },
											// {
											// 	field: 'ye_fee107',
											// 	width: 380,
											// 	title: '商家余额',
											// },
										]
									],
									page: true,
									where: params,
									limit: limit,
									limits: limits,
									request: {
										pageName: 'page',
										limitName: 'size',
									},
									parseData: function(res) { //将原始数据解析成 table 组件所规定的数据
										initChartMoney(res.bills.data)  // 图表数据
										console.log(res.bills,'res.bills11111111')
										return {
											"code": res.code, //解析接口状态
											"msg": res.msg, //解析提示文本
											"count": res.bills.pager.total, //解析数据长度
											"data": res.bills.data ,//解析数据列表
										};
									}
								});
							} else {
								layer.msg(res.msg);
							}
						} else {
							layer.msg('服务器连接错误');
						}
					});
					
				}
				
				
				
				function initChartMoney(vals) {
					console.log(vals,'record')
					console.log(type,'typeaccountname')
				  var chartMoney = echarts.init(document.getElementById('chart-money'));
				  // 指定图表的配置项和数据
				  var xAxisData = []
				  var yAxisData = []
				  xAxisData = (vals.map(v => v.tname)).reverse();
				//   if (type == '1') {
				//   	yAxisData = vals.map(v => v.fee).reverse();
				//   } else if (type == '2') {
				//   	yAxisData = vals.map(v => v.xf_allnum).reverse();
				//   } else if (type == '3') {
				//   	yAxisData = vals.map(v => v.jf_fee).reverse();
				//   } else if (type == '4') {
				// 	yAxisData = vals.map(v => v.ye_fee).reverse();
				//    }
				   if (type == '1') {
				  	yAxisData = vals.map(v => v.fee).reverse();
				  } else if (type == '2') {
				  	yAxisData = vals.map(v => v.xf_allnum).reverse();
				  } else if(_data.scenename=='商家佣金' || _data.scenename=='商家积分'){
				  	yAxisData = vals.map(v => v.jf_fee).reverse();
				  } else if(_data.scenename=='商家余额'){
					yAxisData = vals.map(v => v.ye_fee).reverse();
				   }else if(_data.scenename=='直推奖励'){
					yAxisData = vals.map(v => v.jfzt_money).reverse();
				   } else if(_data.scenename=='间推奖励'){
					yAxisData = vals.map(v => v.jfjt_money).reverse();
				   } else if(_data.scenename=='团队奖励'){
					yAxisData = vals.map(v => v.jftd_money).reverse();
				   } else if(_data.scenename=='积分收入'){
					yAxisData = vals.map(v => v.jfsr_money).reverse();
				   } else if(_data.scenename=='现金收入'){
					yAxisData = vals.map(v => v.xjsr_money).reverse();
				   }
				  // $.each(record, function(index, item) {
				  //   xAxisData.push(item.show_date)
				  //   seriesData.push(item.amount)
				  // })
				  
				  var chartMoneyOption = {
				    tooltip: {
				      trigger: 'axis',
				      axisPointer: {
				        type: 'cross',
				        label: {
				          backgroundColor: '#6a7985'
				        }
				      }
				    },
				    xAxis: {
				      type: 'category',
				      data: xAxisData
				    },
				    yAxis: {
				      type: 'value',
					  data: ''
				    },
					legend: {
						data: [type=='1'?'交易金额':type=='2'?'交易量':type=='3'?'消费积分总额':type=='4'?'总余额':'']
					},
				    series: [
				      {
						name: type=='1'?'交易金额':type=='2'?'交易量':type=='3'?'消费积分总额':type=='4'?'总余额':'',
				        data: yAxisData,
				        type: 'bar',
				        areaStyle: {},
				        itemStyle : { normal: {label : {show: true}}}
				      }
				    ],
				    grid: [
				      {
				        left: '5%',
				        right: '5',
				        top: 40
				      }
				    ]
				  };
				  chartMoney.setOption(chartMoneyOption);
				}
				$('#line_details').css('display','none')
				
				var status='1'
				var tname=''
                //监听TAB
				element.on('tab(changetab)', function(elem) {
					// console.log(elem,'elem0000')
					status = this.getAttribute('lay-id');
					if (status == '2') {
						// 日
						tname = '%Y-%m-%d'
					} else if (status == '3') {
						// 月
						tname = '%Y-%m'
					} else if (status == '4') {
						// 年
						tname = '%Y'
					}
					
					
					if(status=='1' || status=='2'){
						$('#timeall').css('display','inline-block')
						$('#timeMin').css('display','inline-block')
						$('#timeSelect').css('display','none')
					}else if(status=='3'){
						$('#timeall').css('display','inline-block')
						$('#timeMin').css('display','none')
						$('#timeSelect').css('display','inline-block')
						year = num.getFullYear()
						$('select[name=year]').val(year)
						form.render()
						console.log(year,'year00000')
					}else{
						$('#timeall').css('display','none')
					}
					if(status==1){
						$('.layui-table-view').css('display','block')
						$('#line_details').css('display','none')
					}else{
						// if(type=='1'||type=='2'){
						// 	initdataTable()   // 表格数据
						// }else if(type=='3'){
						// 	xflfTable()   // 消费积分总额
						// }else if(type=='4'){
						// 	balanceTable()   // 总余额
						// }
						if(type=='1'){
							initdataTable()   //
						}else if(_data.scenename=='商家佣金' || _data.scenename=='商家积分'){
							xflfTable()
						}else if( _data.scenename=='商家余额'){
							balanceTable()
						}else if(_data.scenename=='直推奖励' || _data.scenename=='间推奖励' || _data.scenename=='团队奖励' || _data.scenename=='积分收入' || _data.scenename=='现金收入'){
							jldataTable() //奖励+商家收入
						}
						$('.layui-table-view').css('display','none')
						setTimeout(()=>{
							$('#line_details').css('display','block')
						},100)
					}
				});
				//监听搜索
				form.verify({
					memberid: function(value, item) { //value：表单的值、item：表单的DOM对象
						if (!value) {
							return '姓名不能为空';
						}
					}
				});

				//监听搜索
				form.on('submit(search)', function(data) {
					// _data = data.field
					if(data){
						_data.customerMobile = data.field.customerMobile
						_data.customerid = data.field.customerid
						_data.endtime = data.field.end_date
						_data.starttime = data.field.stat_date
						_data.year = data.field.year
					}
					if(status=='1'){  // 明细
						initdata();
					}else{
						// if(type=='1'||type=='2'){
						// 	initdataTable()   // 表格数据
						// }else if(type=='3'){
						// 	xflfTable()   // 消费积分总额
						// }else if(type=='4'){
						// 	balanceTable()   // 总余额
                        // }
                        if(type=='1'){
							initdataTable()   //
						}else if(_data.scenename=='商家佣金' || _data.scenename=='商家积分'){
							xflfTable()
						}else if( _data.scenename=='商家余额'){
							balanceTable()
						}else if(_data.scenename=='直推奖励' || _data.scenename=='间推奖励' || _data.scenename=='团队奖励' || _data.scenename=='积分收入' || _data.scenename=='现金收入'){
							jldataTable() //奖励+商家收入
						}
					}
					return false;
				});
				
				function changeUrl(){
					
				}

				$("button[type=reset]").on("click", function() {
					$('input[name=stat_date]').val('')
					$('input[name=end_date]').val('')
					// $('select[name=year]').val()
					// _data = {}
					_data.customerMobile = ""
					_data.customerid = ""
					_data.endtime = ""
					_data.starttime = ""
					_data.year = ""
					if(status=='1'){
						initdata();
					}else{
						// if(type=='1'||type=='2'){
						// 	initdataTable()   // 表格数据
						// }else if(type=='3'){
						// 	xflfTable()   // 消费积分总额
						// }else if(type=='4'){
						// 	balanceTable()   // 总余额
                        // }
                        if(type=='1'){
							initdataTable()   //
						}else if(_data.scenename=='商家佣金' || _data.scenename=='商家积分'){
							xflfTable()
						}else if( _data.scenename=='商家余额'){
							balanceTable()
						}else if(_data.scenename=='直推奖励' || _data.scenename=='间推奖励' || _data.scenename=='团队奖励' || _data.scenename=='积分收入' || _data.scenename=='现金收入'){
							jldataTable() //奖励+商家收入
						}
					}
					document.getElementById("form").reset();
				});

				//监听表格复选框选择
				table.on('checkbox(test-table-operate)', function(obj) {
					console.log(obj)
				});


				//监听工具条
				table.on('tool(test-table-operate)', function(obj) {
					var data = obj.data;
					if (obj.event === 'detail') {
						layer.open({
							type: 2,
							title: '详情',
							shadeClose: false,
							shade: 0.5,
							area: ['600px', '75%'],
							content: 'model/customer_detail.html?id=' + data.memberid,
							end: function() {
								// initdata();
							}
						});
					} else if (obj.event === 'del') {
						layer.confirm('真的删除行么', function(index) {
							obj.del();
							layer.close(index);
						});
					} else if (obj.event === 'edit') {
						layer.open({
							type: 2,
							title: '修改',
							shadeClose: true,
							shade: false,
							maxmin: true, //开启最大化最小化按钮
							area: ['893px', '600px'],
							content: 'model/customer_edit.html?id=' + data.id,
							end: function() {

							}
						});
					} else if (obj.event === 'upreport') {
						layer.open({
							type: 2,
							title: '上传报告',
							shadeClose: false,
							shade: 0.5,
							area: ['500px', '300px'],
							content: 'model/up_report.html?id=' + data.id,
							end: function() {}
						});
					}
				});

				var $ = layui.$,
					active = {
						getCheckData: function() { //获取选中数据
							var checkStatus = table.checkStatus('test-table-operate'),
								data = checkStatus.data;
							layer.alert(JSON.stringify(data));
						},
						getCheckLength: function() { //获取选中数目
							var checkStatus = table.checkStatus('test-table-operate'),
								data = checkStatus.data;
							layer.msg('选中了：' + data.length + ' 个');
						},
						isAll: function() { //验证是否全选
							var checkStatus = table.checkStatus('test-table-operate');
							layer.msg(checkStatus.isAll ? '全选' : '未全选')
						}
					};

				$('.test-table-operate-btn .layui-btn').on('click', function() {
					var type = $(this).data('type');
					active[type] ? active[type].call(this) : '';
				});

			});
		</script>
	</body>
</html>